import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../routes/app_routes.dart';
import 'index_logic.dart';
import 'index_state.dart';

class IndexPage extends StatefulWidget {

  @override
  State<StatefulWidget> createState() => _IndexPageState();

}

class _IndexPageState extends State<IndexPage>{

  final IndexLogic logic = Get.put(IndexLogic());
  final IndexState state = Get.find<IndexLogic>().state;

  @override
  void initState() {

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child:GetBuilder<IndexLogic>(builder: (_){
        return Scaffold(
          // appBar: AppBar(title: Text('${state.seconds} 秒')),
          body: Stack(
            children: [
              Padding(
                  padding: EdgeInsets.only(top: 30 , right: 10),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Container(
                        decoration: BoxDecoration(
                          borderRadius:BorderRadius.circular(10),
                          color: Colors.grey,
                        ),
                        width: 60,
                        height: 40,
                        child: TextButton(
                          onPressed:() {
                            if(state.seconds == 0){
                              logic.goMain();
                            }
                          },
                          child: Text(state.seconds == 0 ? '跳转' : '${state.seconds} 秒',style: TextStyle(color: Colors.white,fontSize: 16)),
                        ),
                      )
                    ],
                ),
              ),
              Center(
                  child: Container(
                    alignment: Alignment.center,
                    child: Text('启动页',style: TextStyle(fontSize: 30,color: Colors.blue)),
                  )
              ),
            ],
          ),
          backgroundColor: Colors.white,
        );
      },)
    );
  }

}
